﻿using MediatR;
using SheepStorage.API.Application.Command.BuildingManagementCommand;
using SheepStorage.API.Application.Command.SheepWeightCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Domain.DTO.Output;
using SheepStorage.Domain.Entity;
using SheepStorage.Service.DataImp;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Application.CommandHandlers.SheepWeightHandler
{
    public class SheepWeightListHandler : IRequestHandler<SheepWeightListCommand, Results<PageOutput<SheepWeight>>>
    {
        private readonly ISheepWeightService service;

        public SheepWeightListHandler(ISheepWeightService service)
        {
            this.service = service;
        }


        public async Task<Results<PageOutput<SheepWeight>>> Handle(SheepWeightListCommand request, CancellationToken cancellationToken)
        {

            return Results<PageOutput<SheepWeight>>.DataResult(await service.GetSheepWeight(request.startDate,request.endDate,
                request.overBit, request.SheepType,request.SheepSex,request.minweightMonth,request.maxweightMonth,request.WeightType,request.pageIndex,request.pageSize));

        }
    }
}
